home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 18067 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: baekdu.rgit.wustl.edu!kks
  2. From: kks@rgit.wustl.edu (Kyeong Soo Kim)
  3. Newsgroups: comp.lang.c,comp.lang.c++
  4. Subject: [Q] Multi-dimensional array problem!!!!!
  5. Date: 18 Apr 1996 19:26:39 GMT
  6. Organization: Washington University, St. Louis, MO
  7. Message-ID: <4l651f$p8v@oldfart.ecl.wustl.edu>
  8. NNTP-Posting-Host: baekdu____,.wustl.edu
  9. Keywords: array
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Dear colleagues,
  13.  
  14.  
  15. I have a difficult problem (?) to be solved for my research.
  16. In most cases, only the size of the array can be input
  17. parameters given at run time with its dimension fixed in
  18. programs. I know this could be done by dynamic allocation
  19. using calloc or malloc as in "Numerical Recipe in C".
  20.  
  21. But, in my case, the dimension as well as the size of the
  22. array is also an input parameter for the program. That is,
  23. while I must treat 3x4 array in one situation, I must treat
  24. 3x4x5 array in the other situation. One of the most simple
  25. example is as follows:
  26.  
  27.  
  28. * Summarize all the elements of the array A[a1][a2]...[an].
  29.  
  30.   sum = 0.0;
  31.   for (i1 = 0; i1 < a1; i1++)
  32.        . . .
  33.          for (in = 0; in < an; in++)
  34.            sum += A[i1][i2]...[in];
  35.  
  36.  
  37. Of course, the above part cannot be implemented with C/C++
  38. as it is. So I don't know how to achieve my purpose.
  39. If would be greatly appreciated if you could give me
  40. any information or advices as soon as possible.
  41. Thanks in advance!
  42.  
  43.  
  44. Kyeong Soo Kim
  45. =================================================================
  46.                         Kim, Kyeong Soo
  47. -----------------------------------------------------------------
  48. Bryan Hall, Room 426                 * EMAIL: kks@rgit.wustl.edu
  49. Department of Electrical Engineering * TEL  : +1-314-935-6157 (O)
  50. Washington University                         +1-314-872-8973 (H)
  51. St. Louis, MO, 63130, USA            * FAX  : +1-314-935-7500 (O)
  52. =================================================================
  53.